package com.epfresh.api.views.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;


import com.epfresh.api.universalimageloader.core.ImageLoader;
import com.epfresh.api.utils.LocalDisplay;
import com.epfresh.api.views.TouchImageView;
import com.epfresh.supplier.R;


/**
 * Created by wzh on 16-7-13.
 */
public class ImageViewDialog extends BaseDialogView implements View.OnClickListener {
    TouchImageView iv;
    @Override
    public void onClick(View view) {

    }




    int min;

    public ImageViewDialog(Context context) {
        super(context);

        init();
    }



    @Override
    public void initBefore() {
        setGravity(Gravity.CENTER);
    }

    @Override
    protected void initAnim() {
        inAnim = new AlphaAnimation(0.0f,1.0f);;
        inAnim.setDuration(300);
        outAnim = new AlphaAnimation(1.0f,0.0f);;
        outAnim.setDuration(300);
        inAnim1 = new AlphaAnimation(0.0f,1.0f);
        inAnim1.setDuration(300);
        outAnim1 = new AlphaAnimation(1.0f,0.0f);
        outAnim1.setDuration(300);
    }

    private void init() {

        iv = new TouchImageView(context);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(LocalDisplay.SCREEN_WIDTH_PIXELS, LocalDisplay.SCREEN_HEIGHT_PIXELS);


        iv.setLayoutParams(lp);


        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Object tag = view.getTag(R.id.item_key_status);
                if (tag instanceof Boolean && (boolean)tag){
                    dismiss();
                }
            }
        });
        contentContainer.addView(iv);
        setCancelable(true);

    }


    public void show(String url){
        ImageLoader.getInstance().displayImage(url,iv);
        show();
    }


}
